#include "srv_time_trigger.hpp"
#include "srv_triggers_runner.hpp"
#include "project_manager/api/pm_trigger.hpp"

/*---------------------------------------------------------------------------*/

namespace Server {

/*---------------------------------------------------------------------------*/


TimeTrigger::TimeTrigger( const ProjectManager::Trigger& _trigger, TriggersRunner& _runner)
	:	m_trigger( _trigger )
	,	m_runner( _runner )
{
	setInterval( m_trigger.getCheckInterval() * 1000  );
	connect( this, SIGNAL( timeout() ), this, SLOT( update() ) );

}


/*---------------------------------------------------------------------------*/


TimeTrigger::~TimeTrigger()
{
	stop();
}


/*---------------------------------------------------------------------------*/


void
TimeTrigger::runTrigger()
{
	start();
}


/*---------------------------------------------------------------------------*/


void
TimeTrigger::update()
{
	m_runner.onTrigger();
}


/*---------------------------------------------------------------------------*/

} // namespace Server
